package com.yugao.fintech.antelope.base.model.module.config.param;

import com.alibaba.fastjson2.JSON;
import com.yugao.fintech.antelope.base.model.constants.ValidationCons;
import com.yugao.fintech.antelope.base.model.enums.ConfigKeyEnum;
import com.yugao.fintech.framework.assistant.utils.StringUtils;
import com.yugao.fintech.framework.desensitization.annotations.FieldSensitive;
import com.yugao.fintech.framework.desensitization.fieldsensitive.enums.StrategyType;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotEmpty;

/**
 * 钉钉配置参数
 *
 
 */
@Getter
@Setter
@Component
@Accessors(chain = true)
public class DingTalkParam extends BaseConfigParam<DingTalkParam> {
    // 应用信息
    /**
     * 应用名称
     */
    @NotEmpty(message = "应用名称不能为空")
    private String name;

    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String agentId;

    // 开发信息
    /**
     * 应用ID
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String appKey;

    /**
     * 应用密钥
     */
    @NotEmpty(message = "应用密钥不能为空")
    @FieldSensitive(StrategyType.RESERVE_4)
    private String appSecret;

    // 功能设置
    /**
     * 授权后返回的域名
     */
    private String authCallbackUrl;

    @Override
    protected DingTalkParam jsonToObject(String json) {
        if (StringUtils.isEmpty(json)) {
            return new DingTalkParam();
        }
        return JSON.parseObject(json, DingTalkParam.class);
    }

    @Override
    public ConfigKeyEnum configKey() {
        return ConfigKeyEnum.DINGTALK;
    }
}
